function d_mt = computeMT( d )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here


d_mt = d;
nT = size(d,1);
d_mt(:,1) = d(:,1) * 40 + 20 * (1:nT)';
d_mt(:,2) = d(:,2) * 40 + 20 * (1:nT)';
sum_mt = d_mt(:,1) + d_mt(:,2);

yResolution = 10000;

policy = zeros(yResolution,nT);

for t = 1 : nT    
    leftB = floor( d_mt(t,1) /sum_mt(t) * yResolution) + 1;
    rightB = ceil( d_mt(t,2) /sum_mt(t) * yResolution);
    policy(1 : (leftB - 1),t) = 1; %left
    policy(leftB : rightB,t) = 3; %Sample
    policy((rightB+1):end,t) = 2; %right;
end


figure;
image( 1:nT, (1:yResolution)/yResolution, policy * 8);
colormap('lines');
ylim([0.25 0.75]);
ylabel('m_R/m','FontWeight', 'bold','FontSize',48);
xlabel('t','FontWeight', 'bold','FontSize',48);
set(gca, 'LineWidth',2,'FontSize',48,...
    'FontWeight','bold','XTick',[100 200 300 400], 'YTick',[0.25 0.5 0.75 1]);
set(gcf,'paperunits','inches');
set(gcf,'papersize',[15 15]);
set(gcf,'paperposition',[0,0,15,15]);
end



function r_MT = mtRate(c)
    s_i = linspace(0,2*pi,100);
    s_0 = 0;%null direction
    d_pref = 40; %drive in preferred direction
    d_null = -20;
    K_MT  = 4;
    r_spont = 20; %spontaneous firing rate
    r_MT = c*(d_pref-d_null) * exp(K_MT * (cos(s_i - s_0) -1)) + ...
       d_null * c + r_spont;
end
